<template>
	<div id="chang">
		<!-- 面包屑导航 -->
		<el-breadcrumb separator-class="el-icon-arrow-right" style="margin-bottom: 20px;">
			<el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
			<el-breadcrumb-item :to="{ path: '/hello' }">咨询分量系统</el-breadcrumb-item>
			<el-breadcrumb-item>分量设置</el-breadcrumb-item>
		</el-breadcrumb>
		<el-card>
				<el-table border :data="changList" style="margin-bottom: 20px;">
					<el-table-column label="名称" prop="AskerName" ></el-table-column>
					<el-table-column label="角色" prop="RoleName"></el-table-column>
					<el-table-column label="权重" prop="Weight"></el-table-column>
					<el-table-column label="备注" prop="BakContent"></el-table-column>
					</el-table-column>
					<el-table-column label="操作">
						<template slot-scope="scope">
							<el-button size="mini" type="success" icon="el-icon-edit" @click="showBox(scope.row)">权重设置
							</el-button>
						</template>
					</el-table-column>
				</el-table>
		</el-card>
		<!-- 修改 -->
		<el-dialog title="编辑用户" :visible.sync="editdialogFormVisible">
			<el-form :model="editform" ref="editFormRef">
				<el-form-item label="权重" prop="Weight" label-width="80px">
					<el-input v-model="editform.Weight"></el-input>
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button v-on:click="editdialogFormVisible = false">取 消</el-button>
				<el-button type="primary" @click="SureEdit">确 定</el-button>
			</div>
		</el-dialog>
		</div>
</template>

<script>
	export default{
		data() {
			return{
				changList:[],
				editdialogFormVisible:false,
				editform: {
					Weight: ''
				}
			}
		},
		mounted() {
			this.GetChangList();
		},
		methods:{
			showBox(row) {
				console.log(row);
				this.editform = row;
				this.editdialogFormVisible = true
			},
			SureEdit() {
				this.$refs.editFormRef.validate(vali => {
					if (!vali) return;
					let _this = this;
					axios.post('/api/api/Chang/EditAk', _this.editform).then(function(res) {
						console.log(res);
						if (res.data.code == 0) {
							_this.editdialogFormVisible = false;
							_this.GetChangList();
							_this.$message.success(res.data.msg);
						}else{
							_this.$message.success(res.data.msg);
						}
					}).catch(function(err) {
						_this.$message.error(err);
					})
				})
			},
			//获取列表
			GetChangList() {
				let _this = this;
				this.$axios.get('/api/api/Chang/GetChangList').then(function(res) {
					console.log(res);
					_this.changList = res.data.data;
				}).catch(function(res) {
					console.log(res);
				});
			}
		}
	}
</script>

<style>
</style>
